<?php
/**
 * 菜洞期数控制中心
 * User：LLW
 * Date：2020-04-08
 * Time：14：09
 */

namespace app\api\controller;

use app\api\model\RaiseModel;
use think\Db;
use think\Request;
use think\response\Json;
use think\Session;

class Raise extends BaseController
{
    //初始化程序
    public function __construct(Request $request = null)
    {
        parent::__construct();
        $this->rais = new RaiseModel();
    }

    /**
     * 期数
     * @return \think\response\Json
     */
    public function Raise()
    {
        $list = $this->rais->getList();
        return $list;
    }

    /**
     * 参与众筹
     * @return \think\response\Json
     */
    public function RaiseCast()
    {
        $res = $this->rais->getCast();
        return $res;
    }

    /**
     * 我的投期
     * @return \think\response\Json
     */
    public function RaiseUser()
    {
        $list = $this->rais->getRaiseUser();
        return $list;
    }

    /*************************    资产操作    ***************************/
    /**
     * 用户提币
     * @return \think\response\Json
     */
    public function MoneyTi()
    {
        $res = $this->rais->getMoneyTi();
        return $res;
    }

    /**
     * 获取充值信息
     */
    public function ConfigImg()
    {
        $request = \think\Request::instance();
        $money = Db::name('user')->where('us_uid',Session::get('uid'))->value('us_points');
        $arr = array('ImgCode'=>$request->domain().tpConfig('Aimg'),'HrefCode'=>tpConfig('Worig'),'money'=>$money,'fei'=>tpConfig('Kfei'));
        AjaxReturn(1,'ok',$arr);
    }
    /**
     * 充币
     * @return \think\response\Json
     */
    public function MoneyCb()
    {
        $res = $this->rais->getMoneyCb();
        return $res;
    }

    /**
     * 上传支付凭证
     * @return Json
     */
    public function ImgZhi()
    {
        $file = $_FILES['image'];
        $res = FileImg($file,'/uploads/article/');
        if($res){
            $data['res'] = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$res;
            $data['res1'] = $res;
            AjaxReturn(1,'上传成功',$data);
        }else{
            AjaxReturn(-1,'error');
        }
    }
}